package entities;

import static forplay.core.ForPlay.*;

import forplay.core.GroupLayer;
import forplay.core.Image;
import forplay.core.ImageLayer;
import forplay.core.ResourceCallback;

public class Katipunero {
  public static String IMAGE = "images/katipunero.png";
  private ImageLayer layer;
  public float angle, x, y;

  public Katipunero(final GroupLayer katipuneroLayer, final float px, final float py) {
    Image image = assetManager().getImage(IMAGE);
    layer = graphics().createImageLayer(image);
    
    x = px;
    y = py;
    
    // Add a callback for when the image loads.
    // This is necessary because we can't use the width/height (to center the
    // image) until after the image has been loaded
    image.addCallback(new ResourceCallback<Image>() {
      @Override
      public void done(Image image) {
        layer.setOrigin(image.width() / 2f, image.height() / 2f);
        layer.setTranslation(x, y);
        katipuneroLayer.add(layer);
      }

      @Override
      public void error(Throwable err) {
        log().error("Error loading image!", err);
      }
    });
  }

  public void update(float delta) {
   // angle += delta;
   // layer.setRotation(angle);
  }
}
